{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "26ScWNvYSgQg"
      },
      "source": [
        "Copyright 2017 Google Inc.\n",
        "\n",
        "Licensed under the Apache License, Version 2.0 (the \"License\");\n",
        "you may not use this file except in compliance with the License.\n",
        "You may obtain a copy of the License at\n",
        "\n",
        "    http://www.apache.org/licenses/LICENSE-2.0\n",
        "\n",
        "Unless required by applicable law or agreed to in writing, software\n",
        "distributed under the License is distributed on an \"AS IS\" BASIS,\n",
        "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
        "See the License for the specific language governing permissions and\n",
        "limitations under the License.\n",
        "\n",
        "\n",
        "# dSprites - Disentanglement testing Sprites dataset\n",
        "\n",
        "## Description\n",
        "Procedurally generated 2D shapes dataset. This dataset uses 6 latents, controlling the color, shape, scale, rotation and position of a sprite (color isn't varying here, its value is fixed).\n",
        "\n",
        "All possible combinations of the latents are present.\n",
        "\n",
        "The ordering of images in the dataset (i.e. shape[0] in all ndarrays) is fixed and meaningful, see below.\n",
        "\n",
        "We chose the smallest changes in latent values that generated different pixel outputs at our 64x64 resolution after rasterization.\n",
        "\n",
        "No noise added, single image sample for a given latent setting.\n",
        "\n",
        "## Details about the ordering of the dataset\n",
        "\n",
        "The dataset was generated procedurally, and its order is deterministic.\n",
        "For example, the image at index 0 corresponds to the latents (0, 0, 0, 0, 0, 0).\n",
        "\n",
        "Then the image at index 1 increases the least significant \"bit\" of the latent:\n",
        "(0, 0, 0, 0, 0, 1)\n",
        "\n",
        "And similarly, till we reach index 32, where we get (0, 0, 0, 0, 1, 0). \n",
        "\n",
        "Hence the dataset is sequentially addressable using variable bases for every \"bit\".\n",
        "Using dataset['metadata']['latents_sizes'] makes this conversion trivial, see below."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "cellView": "both",
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        },
        "colab_type": "code",
        "id": "jJ02BsnqSa96"
      },
      "outputs": [],
      "source": [
        "from __future__ import absolute_import\n",
        "from __future__ import division\n",
        "from __future__ import print_function\n",
        "from matplotlib import pyplot as plt\n",
        "import numpy as np\n",
        "import seaborn as sns\n",
        "\n",
        "# Change figure aesthetics\n",
        "%matplotlib inline\n",
        "sns.set_context('talk', font_scale=1.2, rc={'lines.linewidth': 1.5})\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "output_extras": [
            {
              "item_id": 2
            }
          ]
        },
        "colab_type": "code",
        "executionInfo": {
          "elapsed": 10952,
          "status": "ok",
          "timestamp": 1495021223246,
          "user": {
            "displayName": "",
            "photoUrl": "",
            "userId": ""
          },
          "user_tz": -60
        },
        "id": "uDL3Iw0WFw1L",
        "outputId": "1a3ce845-1add-41c3-ee3d-6018d09423bc"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Keys in the dataset: ['metadata', 'imgs', 'latents_classes', 'latents_values']\n",
            "Metadata: \n",
            " {'description': 'Disentanglement test Sprites dataset.Procedurally generated 2D shapes, from 6 disentangled latent factors.This dataset uses 6 latents, controlling the color, shape, scale, rotation and position of a sprite. All possible variations of the latents are present. Ordering along dimension 1 is fixed and can be mapped back to the exact latent values that generated that image.We made sure that the pixel outputs are different. No noise added.', 'latents_sizes': array([ 1,  3,  6, 40, 32, 32]), 'latents_names': ('color', 'shape', 'scale', 'orientation', 'posX', 'posY'), 'date': 'April 2017', 'version': 1, 'title': 'dSprites dataset', 'latents_possible_values': {'posX': array([ 0.        ,  0.03225806,  0.06451613,  0.09677419,  0.12903226,\n",
            "        0.16129032,  0.19354839,  0.22580645,  0.25806452,  0.29032258,\n",
            "        0.32258065,  0.35483871,  0.38709677,  0.41935484,  0.4516129 ,\n",
            "        0.48387097,  0.51612903,  0.5483871 ,  0.58064516,  0.61290323,\n",
            "        0.64516129,  0.67741935,  0.70967742,  0.74193548,  0.77419355,\n",
            "        0.80645161,  0.83870968,  0.87096774,  0.90322581,  0.93548387,\n",
            "        0.96774194,  1.        ]), 'posY': array([ 0.        ,  0.03225806,  0.06451613,  0.09677419,  0.12903226,\n",
            "        0.16129032,  0.19354839,  0.22580645,  0.25806452,  0.29032258,\n",
            "        0.32258065,  0.35483871,  0.38709677,  0.41935484,  0.4516129 ,\n",
            "        0.48387097,  0.51612903,  0.5483871 ,  0.58064516,  0.61290323,\n",
            "        0.64516129,  0.67741935,  0.70967742,  0.74193548,  0.77419355,\n",
            "        0.80645161,  0.83870968,  0.87096774,  0.90322581,  0.93548387,\n",
            "        0.96774194,  1.        ]), 'scale': array([ 0.5,  0.6,  0.7,  0.8,  0.9,  1. ]), 'orientation': array([ 0.        ,  0.16110732,  0.32221463,  0.48332195,  0.64442926,\n",
            "        0.80553658,  0.96664389,  1.12775121,  1.28885852,  1.44996584,\n",
            "        1.61107316,  1.77218047,  1.93328779,  2.0943951 ,  2.25550242,\n",
            "        2.41660973,  2.57771705,  2.73882436,  2.89993168,  3.061039  ,\n",
            "        3.22214631,  3.38325363,  3.54436094,  3.70546826,  3.86657557,\n",
            "        4.02768289,  4.1887902 ,  4.34989752,  4.51100484,  4.67211215,\n",
            "        4.83321947,  4.99432678,  5.1554341 ,  5.31654141,  5.47764873,\n",
            "        5.63875604,  5.79986336,  5.96097068,  6.12207799,  6.28318531]), 'shape': array([ 1.,  2.,  3.]), 'color': array([ 1.])}, 'author': 'lmatthey@google.com'}\n"
          ]
        }
      ],
      "source": [
        "# Load dataset\n",
        "dataset_zip = np.load('dsprites_ndarray_co1sh3sc6or40x32y32_64x64.npz')\n",
        "\n",
        "print('Keys in the dataset:', dataset_zip.keys())\n",
        "imgs = dataset_zip['imgs']\n",
        "latents_values = dataset_zip['latents_values']\n",
        "latents_classes = dataset_zip['latents_classes']\n",
        "metadata = dataset_zip['metadata'][()]\n",
        "\n",
        "print('Metadata: \\n', metadata)\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        },
        "colab_type": "code",
        "id": "9RWpIJtiHYUL"
      },
      "outputs": [],
      "source": [
        "# Define number of values per latents and functions to convert to indices\n",
        "latents_sizes = metadata['latents_sizes']\n",
        "latents_bases = np.concatenate((latents_sizes[::-1].cumprod()[::-1][1:],\n",
        "                                np.array([1,])))\n",
        "\n",
        "def latent_to_index(latents):\n",
        "  return np.dot(latents, latents_bases).astype(int)\n",
        "\n",
        "\n",
        "def sample_latent(size=1):\n",
        "  samples = np.zeros((size, latents_sizes.size))\n",
        "  for lat_i, lat_size in enumerate(latents_sizes):\n",
        "    samples[:, lat_i] = np.random.randint(lat_size, size=size)\n",
        "\n",
        "  return samples\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        },
        "colab_type": "code",
        "id": "W8LKpGjGKaiN"
      },
      "outputs": [],
      "source": [
        "# Helper function to show images\n",
        "def show_images_grid(imgs_, num_images=25):\n",
        "  ncols = int(np.ceil(num_images**0.5))\n",
        "  nrows = int(np.ceil(num_images / ncols))\n",
        "  _, axes = plt.subplots(ncols, nrows, figsize=(nrows * 3, ncols * 3))\n",
        "  axes = axes.flatten()\n",
        "\n",
        "  for ax_i, ax in enumerate(axes):\n",
        "    if ax_i \u003c num_images:\n",
        "      ax.imshow(imgs_[ax_i], cmap='Greys_r',  interpolation='nearest')\n",
        "      ax.set_xticks([])\n",
        "      ax.set_yticks([])\n",
        "    else:\n",
        "      ax.axis('off')\n",
        "\n",
        "def show_density(imgs):\n",
        "  _, ax = plt.subplots()\n",
        "  ax.imshow(imgs.mean(axis=0), interpolation='nearest', cmap='Greys_r')\n",
        "  ax.grid('off')\n",
        "  ax.set_xticks([])\n",
        "  ax.set_yticks([])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "lXSlqKKAJirL"
      },
      "source": [
        "## Randomly sampling into the dataset"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 24,
      "metadata": {
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "output_extras": [
            {
              "item_id": 1
            }
          ]
        },
        "colab_type": "code",
        "executionInfo": {
          "elapsed": 1282,
          "status": "ok",
          "timestamp": 1495021397861,
          "user": {
            "displayName": "",
            "photoUrl": "",
            "userId": ""
          },
          "user_tz": -60
        },
        "id": "MFJLYKK5RzbH",
        "outputId": "270d35ee-f376-47a1-9f88-1b279f70c2ca"
      },
      "outputs": [
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAA1MAAANTCAYAAABLuEecAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHFNJREFUeJzt3dt22ziiRVHzjPz/L/M8VKtKcWxHWryCnPOpO3ZsjgpE\naWMD4DTP8/wBAADAW/7v6AsAAAAYkTAFAAAQCFMAAACBMAUAABAIUwAAAIEwBQAAEPz66YvTNO11\nHVzYnqfvG7OsYe8nRhi3LGXMMhpjltF8N2Y1UwAAAIEwBQAAEAhTAAAAgTAFAAAQCFMAAACBMAUA\nABAIUwAAAIEwBQAAEAhTAAAAgTAFAAAQCFMAAACBMAUAABAIUwAAAIEwBQAAEAhTAAAAgTAFAAAQ\nCFMAAACBMAUAABD8OvoCAACA+5jn+a/fM03TDleynGYKAAAgEKYAAAACy/wAAIBNvbK076fvP+uy\nP80UAABAoJkCAAA28W4j9crPOVNLpZkCAAAINFMAAMCq1mqkzk4zBQAAEAhTAADAMOZ5Pk3zJUwB\nAAAEwhQAAEAgTAEAAATCFAAAQCBMAQAAwznDQRTCFAAAQOChvQAAwCqObor2ppkCAAAIhCkAAIBA\nmAIAAAiEKQAAgECYAgAACIQpAACAQJgCAAAIhCkAAIBAmAIAAIY1z/NhDwsWpgAAAAJhCgAAIPh1\n9AUAcC2vLLWYpmmHKwFgb4/7+1HL7vammQIA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UAABBopmBD7z7Y14wRAMA4NFMAAACBZgp28tM+Ko0UALAFnzG2pZkCAAAI\nhCkAAIDAMj/YmbodANiKzxn70kwBAAAEmikAABicRuoYmikAAIBAMwUAABv66fEoS34ex9NMAQAA\nBJopAADYwVeN0ndtlfZpDJopAACAQJgCAAAILPMDAICDWM43Ns0UAABAIEwBAAAEwhQAAEAgTAEA\nAATCFAAAQCBMAQAABMIUAABAIEwBAAAEwhQAAEAgTAEAAATCFAAAQCBMAQAABMIUAABAIEwBAAAE\nwhQAAEAgTAEAAATCFAAAQCBMAQAABMIUAABAIEwBAAAEwhQAAEAgTAEAAATCFAAAQCBMAQAABMIU\nAABAIEwBAAAEwhQAAEAgTAEAAATCFAAAQCBMAQAABMIUAABAIEwBAAAEwhQAAEAgTAEAAATCFAAA\nQCBMAQAABMIUAABAIEwBAAAEwhQAAEAgTAEAAATCFAAAQCBMAQAABNM8z/PRFwEAADAazRQAAEAg\nTAEAAATCFAAAQCBMAQAABMIUAABAIEwBAAAE/w8+tTl1Vs2yrAAAAABJRU5ErkJggg==\n",
            "text/plain": [
              "\u003cmatplotlib.figure.Figure at 0xda7bb10\u003e"
            ]
          },
          "metadata": {
            "tags": []
          },
          "output_type": "display_data"
        }
      ],
      "source": [
        "# Sample latents randomly\n",
        "latents_sampled = sample_latent(size=5000)\n",
        "\n",
        "# Select images\n",
        "indices_sampled = latent_to_index(latents_sampled)\n",
        "imgs_sampled = imgs[indices_sampled]\n",
        "\n",
        "# Show images\n",
        "show_images_grid(imgs_sampled)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 25,
      "metadata": {
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "output_extras": [
            {
              "item_id": 1
            }
          ]
        },
        "colab_type": "code",
        "executionInfo": {
          "elapsed": 125,
          "status": "ok",
          "timestamp": 1495021398201,
          "user": {
            "displayName": "",
            "photoUrl": "",
            "userId": ""
          },
          "user_tz": -60
        },
        "id": "IygFe_LtLoUg",
        "outputId": "8ce35c72-f502-4f8f-d0c6-71ae645662c4"
      },
      "outputs": [
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZ0AAAGdCAYAAADJ366iAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGOxJREFUeJzt3duOHEWzBtD0j+2xMQYh8f6PCPIBHwHva6T+QkTudPRM\nz1qX1dOVdWqCkj5HPPn27du3BQAD/nftAwDg8VB0ABij6AAwRtEBYIyiA8AYRQeAMU+rD588eTJ1\nHADckPSvcbzpADBG0QFgjKIDwBhFB4Axig4AYxQdAMYoOgCMUXQAGKPoADBG0QFgjKIDwBhFB4Ax\nig4AYxQdAMYoOgCMUXQAGKPoADBG0QFgjKIDwBhFB4Axig4AYxQdAMYoOgCMUXQAGKPoADBG0QFg\njKIDwBhFB4Axig4AY55e+wD47548efLd1/j27dt3X+M+qq5t+ixdq+7fn1St0X1+Tj5v3XN/rM/h\nY+BNB4Axig4AYxQdAMYoOgCMUXQAGKPoADBGZPpKduKo6TsTUeoJOzHZ7rn/73+X/z9rZ+1uZHpn\nX93tP/zwQ3vt7jHtnN/Ede9u5zq86QAwRtEBYIyiA8AYRQeAMYoOAGOk176zncRZSvpcs2Fjko51\nZ/2TKaOTaakknd8///xzbF8nm4p2jytdw53z66rO41R67WRyjv/Omw4AYxQdAMYoOgCMUXQAGKPo\nADBGeu2QbuJsZzxy2v706eXbWCXLTjnZh+tkz7JTabDd75xyMi3VTZ1NJLXSMe2k1/7+++/WGidJ\ntf133nQAGKPoADBG0QFgjKIDwBhFB4Ax0mtN3cmM6e+rZFn3O2l7dazdJNxE6munX1o3mXRyYms3\nhbeTyErnt9P3rZsUO3ke3b+v9pNSat1ecWk/1XcS6bX/zpsOAGMUHQDGKDoAjFF0ABij6AAwRtEB\nYMyjiEyfHPN8qunms2fP4hrdyPTd3V3cV5LW78av//rrr7hGulZpX91o8lprffny5eL2k006u9/p\nxurXyvHdbpR6Jwbcfd52GmiebN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axig4AYxQdAMYoOgCMUXQAGKPoADBG0QFgjKIDwBhFB4Axig4AYxQd\nAMYoOgCMUXQAGKPoADBG0QFgjKIDwBhFB4Axig4AY55WH3779m3qOAB4BLzpADBG0QFgjKIDwBhF\nB4Axig4AYxQdAMb8H9bP1DAOnAvsAAAAAElFTkSuQmCC\n",
            "text/plain": [
              "\u003cmatplotlib.figure.Figure at 0xda7ba90\u003e"
            ]
          },
          "metadata": {
            "tags": []
          },
          "output_type": "display_data"
        }
      ],
      "source": [
        "# Compute the density of the data to show that no pixel ever goes out of\n",
        "# the boundary. Obviously it also means that the main support of the pixels is in the center\n",
        "# half. \n",
        "# Locations cover a square, which make the aligned X-Y latents more likely for\n",
        "# models to discover.\n",
        "\n",
        "show_density(imgs_sampled)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "peJaYLHyLKDu"
      },
      "source": [
        "## Conditional sampling of the dataset"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 27,
      "metadata": {
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "output_extras": [
            {
              "item_id": 1
            },
            {
              "item_id": 2
            }
          ]
        },
        "colab_type": "code",
        "executionInfo": {
          "elapsed": 551,
          "status": "ok",
          "timestamp": 1495021412038,
          "user": {
            "displayName": "",
            "photoUrl": "",
            "userId": ""
          },
          "user_tz": -60
        },
        "id": "6DYLZkFJQjb9",
        "outputId": "601edffd-fa13-474b-e61c-0c476f00b52d"
      },
      "outputs": [
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgQAAAIECAYAAABmAjaWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAC7pJREFUeJzt3cty20YARcHDlP//l5EVqxSaQvgAMAOyexk7khZj1eEd\nULosy7IEAHy1f0Z/AQDAeIIAABAEAIAgAAASBABAggAAqP6s/eHlcjnq6+BLHP0uV2eYrY14p7Zz\nzJZ+O8MWAgBAEAAAgg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n2Xn8PBYCAGDcQrD32188V8CncIY5mjP3nSwEAIAgAAA+7KFC\nONJRbzF0/QUcwUIAAMyxEOz5AzK8umJro374kLfVAnuyEAAAcywEcCav/iCXLVm+gK1ZCAAAQQAA\nTBYEl8vFBMopObvA2U0VBADAGFM+VLj37zmAvczwwCHAKywEAMCcC8FP7/7QIve6jLbHD95yroGt\nWQgAAEEAAJzgyuDq2Ye1TKrMZs/f2QHwLgsBAHCeheAeKwBntHZu/UZDYBQLAQBw7oUAPo1VABjF\nQgAACAIAQBAAAAkCACBBAAAkCACABAEAkCAAABIEAECCAABIEAAACQIAIEEAACQIAIAEAQCQIAAA\nEgQAQIIAAEgQAAAJAgAgQQAAJAgAgAQBAJAgAAASBABAggAASBAAAAkCACBBAAAkCACABAEAkCAA\nABIEAECCAABIEAAACQIAIEEAACQIAIAEAQCQIAAAEgQAQIIAAEgQAAAJAgAgQQAAJAgAgAQBAJAg\nAAASBABAggAASBAAAAkCACBBAAAkCACABAEAkCAAABIEAECCAABIEAAACQIAIEEAACQIAIAEAQCQ\nIAAAEgQAQIIAAEgQAAAJAgAgQQAAVJdlWZbRXwQAMJaFAAAQBACAIAAAEgQAQIIAAEgQAADVvw1M\nDOSLs4jOAAAAAElFTkSuQmCC\n",
            "text/plain": [
              "\u003cmatplotlib.figure.Figure at 0xe13c850\u003e"
            ]
          },
          "metadata": {
            "tags": []
          },
          "output_type": "display_data"
        },
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZ0AAAGdCAYAAADJ366iAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAENlJREFUeJzt3ely3Ea6BNCiRIraPN70/g/oCC/aKYoW5wWQpVu4mOwm\ndc7P6qXQoGfSiEh/dXF/f38/AKDgyakvAIAfh9ABoEboAFAjdACoEToA1AgdAGouZy9eXFy0rgOA\nRyT91ziedACoEToA1AgdAGqEDgA1QgeAGqEDQI3QAaBG6ABQI3QAqBE6ANQIHQBqh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0AKgROgDUCB0AaoQOADVCB4AaoQNA\njdABoEboAFAjdACoEToA1AgdAGqEDgA1QgeAGqEDQI3QAaBG6ABQI3QAqBE6ANQIHQBqhA4ANUIH\ngBqhA0CN0AGgRugAUCN0AKi5nL14f3/fug4AfgCedACoEToA1AgdAGqEDgA1QgeAGqEDQM1/AeBx\nf3G3dER6AAAAAElFTkSuQmCC\n",
            "text/plain": [
              "\u003cmatplotlib.figure.Figure at 0xe13c790\u003e"
            ]
          },
          "metadata": {
            "tags": []
          },
          "output_type": "display_data"
        }
      ],
      "source": [
        "## Fix posX latent to left\n",
        "latents_sampled = sample_latent(size=5000)\n",
        "latents_sampled[:, -2] = 0\n",
        "indices_sampled = latent_to_index(latents_sampled)\n",
        "imgs_sampled = imgs[indices_sampled]\n",
        "\n",
        "# Samples\n",
        "show_images_grid(imgs_sampled, 9)\n",
        "\n",
        "# Show the density too to check\n",
        "show_density(imgs_sampled)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 29,
      "metadata": {
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          },
          "output_extras": [
            {
              "item_id": 1
            },
            {
              "item_id": 2
            }
          ]
        },
        "colab_type": "code",
        "executionInfo": {
          "elapsed": 708,
          "status": "ok",
          "timestamp": 1495021438003,
          "user": {
            "displayName": "",
            "photoUrl": "",
            "userId": ""
          },
          "user_tz": -60
        },
        "id": "l2g-xquoTJaG",
        "outputId": "3e3df869-eab7-4428-9749-81440506f0d6"
      },
      "outputs": [
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgQAAAIECAYAAABmAjaWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAC3FJREFUeJzt3dtu20YARdHNwv//y+yTANmIbF3JGXKttyKpI9Sssn2G\nkpZ1XdcAgFP7b+8HAADsTxAAAIIAABAEAECCAABIEAAA1ddvv7gsy1aPg5PY+lWurmHebY9XaruO\neadb17CFAAAQBACAIAAAEgQAQI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fntJomUA5mYh\nAAAEAQDgyAB4guMBOB4LAQAgCG5Z13Wzz4gHgL0JAgDAPQQ//VwFrv/ZuSkAR2UhAAAEAQDgyKC6\n7/3Zr3+fowMAjsZCAACceyF49mWFlgIAjsZCAACccyF41xsOWQoAOAoLAQAgCACAEx0ZfPJzCbyb\nIQCzsxAAAMdfCLb+xEI3GgIwIwsBAHD8hWBrlgEAZmQhAAAEAQBwgiBYlsWMDwB/OHwQAAB/O81N\nhdcrwbtfimiBAGB2FgIA4DwLwbXLT/SvLgWWAQCOwkIAAAgCAOCkRwYXzx4dOCoA4GgsBADAuReC\ni3tfkmgZAOCoLAQAgIXgp5/3FVgFADgDCwEAIAgAAEcGNzkqAOBMLAQAgCAAAAQBAJAgAAASBABA\nggAASBAAAAkCACBBAAAkCACABAEAkCAAABIEAECCAABIEAAACQIAIEEAACQIAIAEAQCQIAAAEgQA\nQIIAAKiWdV3XvR8EALAvCwEAIAgAAEEAACQIAIAEAQCQIAAAqv8Bh0zoxBjQyPYAAAAASUVORK5C\nYII=\n",
            "text/plain": [
              "\u003cmatplotlib.figure.Figure at 0x107de190\u003e"
            ]
          },
          "metadata": {
            "tags": []
          },
          "output_type": "display_data"
        },
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZ0AAAGdCAYAAADJ366iAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGPtJREFUeJzt3dmSHMWyBdDQATQzGcb/fyAPoFktBt3nY7e2czwIvKpb\naz1mdWXkVHLSbOP+6PPnz58XAAz4z7UPAIAvh6IDwBhFB4Axig4AYxQdAMYoOgCM+br68NGjR1PH\nAcADkv5vHG86AIxRdAAYo+gAMEbRAWCMogPAGEUHgDGKDgBjFB0Axig6AIxRdAAYo+gAMEbRAWCM\nogPAGEUHgDGKDgBjFB0Axig6AIxRdAAYo+gAMEbRAWCMogPAGEUHgDGKDgBjvr72AcDfefToUfzs\n8+fPg0cC/FPedAAYo+gAMEbR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jFF0ABjz\nRUemk53IdDcmWx1TNwK902Cye7w7EdJ0XClWuxNh7za+7I6F3rEzEvtUvPxkpLfbxHatfsPPk01F\nu89odT9Eo/85kWkArk7RAWCMogPAGEUHgDGKDgBjvoj0WrJzfqdSRlUiq9tgciKRdTItdXJfO41I\nL6kasJ463p00YXeNnYaf3X11x3dX++o2At1ZQ/PO65BeA+DqFB0Axig6AIxRdAAYo+gAMOaLTq/t\n6F6TnWvYTaOlW1itfTJ51V1jop/Yzpjwron0Wkpepe07KbxkJ0HWTYrt9Hc7uS/+PdJrAFydogPA\nGEUHgDGKDgBjFB0AxkivXclE37edBNA1e6xN9Irrbl/rXP+zqqfeqYTVznmcvB+nzqPaz06qjnnS\nawBcnaIDwBhFB4Axig4AYxQdAMYoOgCMEZl+AE7ep4nmiCdj2afWnrAzSnri3l6zAatR0g+XyDQA\nV6foADBG0QFgjKIDwBhFB4Ax0muwaSKF1/0N3rfGrFJqD5f0GgBXp+gAMEbRAWCMogPAGEUHgDHS\nawAcJ70GwNUpOgCMUXQAGKPoADBG0QFgjKIDwBhFB4Axig4AYxQdAMYoOgCMUXQAGKPoADBG0QFg\njKIDwBhFB4Axig4AYxQdAMYoOgCMUXQAGKPoADBG0QFgjKIDwBhFB4Axig4AY76uPvz8+fPUcQDw\nBfCmA8AYRQeAMYoOAGMUHQDGKDoAjFF0ABjzf5SQF56OdHY9AAAAAElFTkSuQmCC\n",
            "text/plain": [
              "\u003cmatplotlib.figure.Figure at 0x134157d0\u003e"
            ]
          },
          "metadata": {
            "tags": []
          },
          "output_type": "display_data"
        }
      ],
      "source": [
        "## Fix orientation to 0.8 rad\n",
        "latents_sampled = sample_latent(size=5000)\n",
        "latents_sampled[:, 3] = 5\n",
        "indices_sampled = latent_to_index(latents_sampled)\n",
        "imgs_sampled = imgs[indices_sampled]\n",
        "\n",
        "# Samples\n",
        "show_images_grid(imgs_sampled, 9)\n",
        "\n",
        "# Density should not be different than for all orientations\n",
        "show_density(imgs_sampled)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "autoexec": {
            "startup": false,
            "wait_interval": 0
          }
        },
        "colab_type": "code",
        "id": "-FCACtAlqKTA"
      },
      "outputs": [],
      "source": [
        ""
      ]
    }
  ],
  "metadata": {
    "colab": {
      "default_view": {},
      "last_runtime": {
        "build_target": "",
        "kind": "local"
      },
      "name": "deepmind_2d_shapes_dataset_public.ipynb",
      "provenance": [
        {
          "file_id": "/piper/depot/google3/experimental/deepmind/concepts/dataset2dshapes/public/deepmind_2d_shapes_dataset.ipynb?workspaceId=lmatthey:lmatthey-2dshapes-dataset:580:citc",
          "timestamp": 1493149332589
        },
        {
          "file_id": "0BxLiVtkN33-wbmVnbVQwcUhjY0U",
          "timestamp": 1493149291483
        }
      ],
      "version": "0.3.2",
      "views": {}
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
